<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <button id="btn1">发送请求1</button>
    <button id ="btn2">发送请求2</button>
    <hr/>
    <h1>loading...</h1>
    <script>

      
   //          btn1.onclick=function(){
   //              var btn1 = document.getElementById('btn1');
   //              var xhr  = new XMLHttpRequest();
   //              var info;
   //              var H1 =document.getElementsByTagName('h1')[0];
   //              xhr.open('get','http://127.0.0.1:8000/changeH1.html',true);
   //              xhr.send();
   //              xhr.onreadystatechange= function(){
                   
   //              if(xhr.readyState==4 && xhr.status==200){
   //                 console.log(xhr.responseText)
   //                    H1.innerHTML="hello!你好"
            
   //        }
   //    }

   // } 
              btn2.onclick = function() {
                  var btn2 = document.getElementById('btn2');
                  var xhr = new XMLHttpRequest();
                  var info;
                  var h1 = document.getElementsByTagName('h1')[0]
                  xhr.open('get','info.txt',true);
                  xhr.send();
                  xhr.onreadystatechange = function(){
                    if(xhr.readyState == 4 && xhr.status ==200){
                      info = xhr.responseText;
                      h1.innerHTML = '你好啊世界';
                      console.log(info)
                    }
                  }
              }   
        
    </script>
</body>
</html>